package com.haocang.szgm.ui.msg.adapter;

import android.content.Context;

import com.haocang.szgm.R;
import com.haocang.szgm.ui.waterpoint.bean.WaterPointBean;
import com.haocang.commonlib.recyclerView.BaseAdapter;
import com.haocang.commonlib.recyclerView.BaseViewHolder;
import com.haocang.szgm.utils.tools.CacheData;
import com.haocang.szgm.utils.tools.MyTextUtils;

/**
 * 创建时间：2019/3/22
 * 编 写 人：ShenC
 * 功能描述：
 */

public class TaskListAdapter extends BaseAdapter<WaterPointBean> {

    public TaskListAdapter(Context context) {
        super(context, R.layout.item_task_list);
    }

    @Override
    public void convert(BaseViewHolder holder, WaterPointBean bean) {

        holder.setText(R.id.tv_name, bean.getLocation())
                .setImageResource(R.id.iv_type, R.drawable.ic_water_01);


        if(MyTextUtils.IsNullByString(bean.getStatus())){
            holder.setVisible(R.id.tv_status, false);
        }else{
            holder.setVisible(R.id.tv_status, true);


            switch (bean.getIsDelete()) {
                case "S":
                    switch (bean.getStatus()) {
                        case "0":
                            holder.setText(R.id.tv_status, "未处置")
                                  .setBackgroundResource(R.id.tv_status, R.drawable.bt_red_01);
                            break;
                        case "1":
                            holder.setText(R.id.tv_status, "处置中")
                                  .setBackgroundResource(R.id.tv_status, R.drawable.bt_orange_01);
                            break;
                        case "2":
                            holder.setText(R.id.tv_status, "已处置")
                                    .setBackgroundResource(R.id.tv_status, R.drawable.bt_green_01);
                            break;
                    }
                    break;
                case "Y":
                    holder.setText(R.id.tv_status, "未积水")
                            .setBackgroundResource(R.id.tv_status, R.drawable.bt_green_01);
                    break;
                case "N":
                    holder.setText(R.id.tv_status, "未确认").setBackgroundResource(R.id.tv_status, R.drawable.bt_gray_02);
                    if (bean.getIsHandle() == 1) {
                        holder.setText(R.id.tv_status, "预处理") .setBackgroundResource(R.id.tv_status, R.drawable.bt_green_01);
                    }
                    break;
                default:
                    holder.setVisible(R.id.tv_status, false);
                    break;
            }
        }
        if (MyTextUtils.IsNullByString(bean.getCreateDT())) {
            holder.setVisible(R.id.tv_num, false);
        } else {
            holder.setVisible(R.id.tv_num, false);
        }

        if(bean.getIsUrgentHandle() == 0){
            holder.setVisible(R.id.tv_IsUrgentHandle, false);
        }else{
            holder.setVisible(R.id.tv_IsUrgentHandle, true);
        }

        if(bean.getDisposingPerson() !=null && bean.getDisposingPerson().indexOf(CacheData.UserID()) > -1){
            holder.setVisible(R.id.tv_mytast, true);
        }else{
            holder.setVisible(R.id.tv_mytast, false);
        }

        holder.setText(R.id.tv_context, bean.getSeeperReason())
                .setText(R.id.tv_dt, bean.getCreateDT() == null ? "" : MyTextUtils.GetSimpleDtName(bean.getCreateDT()));
    }

}
